package com.exam.service.impls;

import com.exam.domain.Grade;
import com.exam.domain.Rank;
import com.exam.domain.TeacherGrade;
import com.exam.mapper.GradeMapper;
import com.exam.mapper.RankMapper;
import com.exam.mapper.TeacherGradeMapper;
import com.exam.service.interfaces.GradeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by jly on 2017/3/2.
 */
@Service("gradeService")
public class GradeServiceImpl implements GradeService {
    @Resource
    private GradeMapper gradeMapper;
    @Resource
    private RankMapper rankMapper;
    @Resource
    private TeacherGradeMapper teacherGradeMapper;

    /**
     * 查看成绩列表具体数据
     *
     * @return 返回成绩列表及相关信息
     * @since 2017-3-2
     * @author jly
     * */
    @Override
    public List<Grade> gradeLists(String studentname, Integer kindId, Integer rankId, String starttime) {
        return gradeMapper.gradeLists(studentname,kindId, rankId,starttime);
    }

    /**
     * 查询所有等级
     *
     * @return: 返回数据库等级表所有内容
     * @Since: 2017-3-2
     * @author: jly
     * */
    @Override
    public List<Rank> allRanks() {
        return rankMapper.allRanks();
    }

    /**
     * 查询考试开始时间
     *
     * @return:
     * @Since: 2017-3-19
     * @author: jly
     * */
    @Override
    public List<Grade> allTime() {
        return gradeMapper.allTime();
    }

    /**
     * 进入学生成绩统计界面
     *
     * @return: 进入学生成绩统计界面
     * @since: 2017-3-19
     * @author: jly
     * */
    @Override
    public List<Grade> studentGrades2(Integer kindId, String starttime, String endtime) {
        return gradeMapper.studentGrades2(kindId,starttime,endtime);
    }

    /**
     * 查询需要判分的主观题
     *
     *@since 2017-3-20
     *@author jly
     * */
    @Override
    public List<TeacherGrade> queryteacherGrades() {
        return teacherGradeMapper.queryteacherGrades();
    }

    /**
     * 给questiongrade赋值
     *
     * @since 2017-3-20
     * @author jly
     * */
    @Override
    public boolean giveMarks(Integer questiongrade, Integer id, Integer questionid, String createtime, Integer gradeid) {
        return teacherGradeMapper.giveMarks(questiongrade,id,questionid,createtime,gradeid);
    }

    /**
     * 根据gradeid查询相关信息集
     *
     * @since 2017-3-20
     * @author jly
     * */
    @Override
    public List<TeacherGrade> queryTeacherGradelist(Integer gradeid) {
        return teacherGradeMapper.queryTeacherGradelist(gradeid);
    }

    /**
     * 更新成绩表成绩
     *
     * @since 2017-3-20
     * @author jly
     * */
    @Override
    public boolean updataGrade(Integer gradeid, int sumgrade, int rank) {
        return teacherGradeMapper.updataGrade(gradeid,sumgrade,rank);
    }

    /**
     * 根据gradeid删除老师判分表数据
     *
     * @since 2017-3-20
     * @author jly
     * */
    @Override
    public boolean delteachergrade(Integer gradeid) {
        return teacherGradeMapper.delteachergrade(gradeid);
    }
}
